home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
Shareware
/
IDimager Personal 4.2.0.3
/
setup_IDimager_Personal_V4.exe
/
{app}
/
web
/
modules
/
labeltree.psc
< prev
next >
Wrap
Text File
|
2008-06-04
|
7KB
|
188 lines
%code
const
cIndentString = ' '; // the trailing space is required for IE
var
AShowCounts: Boolean;
function StringRepeat(AString: WideString; ARepeat: Integer): WideString;
var
i: Integer;
begin
result := toWideString('');
for i := 1 to ARepeat do
result := result + AString;
end;
function FormatResult (AGUID: String; AName: WideString; ACount: Integer);
begin
result := toWideString('');
result := result + '<a href="javascript:getHTML(''%var:PageOffset/./modules/labelimages.psc'', ''thumbs'', ''GUID=' + AGUID + ''');">';
if AShowCounts then
result := result + WideFormat ('%s [%d]', [AName, ACount])
else
result := result + AName;
result := result + '</a>';
end;
var
AParentGUID: String;
ALink: WideString;
ALevel: Integer;
ACats: TCatalogPropCategories;
ACat: TCatalogPropCategory;
ACatParent: Boolean;
AProps: TCatalogItemProps;
AParent, AProp: TCatalogItemProp;
i: Integer;
AExpand: Boolean;
begin
result := toWideString('');
AShowCounts := (Request.Params.Values['showCounts'] = 'y');
AParentGUID := Trim(Request.Params.Values['GUID']);
if AParentGUID = '' then
AParentGUID := 'top';
AExpand := Request.Params.Values['expand'] ='y';
if not IsValidNumberString(Request.Params.Values['level'], False) then
ALevel := 0
else
ALevel := StrToInt(Request.Params.Values['level']);
if AParentGUID = 'top' then
begin
ACats := TCatalogPropCategories.Create (TCatalogPropCategory, '');
Catalog.EnumCategories (ACats, AShowCounts);
for i := 0 to ACats.Count - 1 do
begin
ACat := ACats.Items[i];
ALink := 'javascript:getHTML(''%var:PageOffset/./modules/labeltree.psc'', ''' + ACat.GUID + ''', ''GUID=' + ACat.GUID + '&showCounts=' + iif(AShowCounts, 'y', 'n') + '&expand=y&level=' + IntToStr(ALevel + 1) + ''')';
result := result + '<div id="' + ACat.GUID + '">';
if Catalog.CategoryHasSubs (ACat) then
begin
result := result + '<a href="' + ALink + '">' +
' <img src="%var:PageOffset/images/expand.gif">' +
'</a> ' +
'<a href="' + ALink + '">' +
ACat.CategoryName +
'</a>' +
'';
end
else
result := result + '<img src="%var:PageOffset/images/noindent.gif"> ' +
ACat.CategoryName +
'<br/>';
result := result + '</div>';
end;
ACats.Free;
end
else
begin
ACatParent := False;
AParent := TCatalogItemProp.Create(nil);
if ALevel = 1 then
begin
ACat := TCatalogPropCategory.Create(nil);
if Catalog.EnumCategory (AParentGUID, ACat, AShowCounts) then
begin
AParent.GUID := ACat.GUID;
AParent.PropName := ACat.CategoryName;
AParent.PhotoCount := ACat.PhotoCount;
ACatParent := True;
end;
ACat.Free;
end
else
begin
Catalog.EnumProp (AParentGUID, AParent, AShowCounts);
end;
if AExpand then
begin
if ACatParent then
ALink := 'javascript:getHTML(''%var:PageOffset/./modules/labeltree.psc'', ''' + AParent.GUID + ''', ''GUID=' + AParent.GUID + '&showCounts=' + iif(AShowCounts, 'y', 'n') + '&expand=n&level=' + IntToStr(ALevel) + ''')'
else
ALink := 'javascript:getHTML(''%var:PageOffset/./modules/labeltree.psc'', ''' + AParent.GUID + ''', ''GUID=' + AParent.GUID + '&showCounts=' + iif(AShowCounts, 'y', 'n') + '&expand=n&level=' + IntToStr(ALevel) + ''')';
result := result + StringRepeat(cIndentString, ALevel - 1) +
'<a href="' + ALink + '">' +
' <img src="%var:PageOffset/images/collapse.gif">' +
'</a> ' +
iif (ACatParent,
'<a href="' + ALink + '">' + AParent.PropName + '</a>',
FormatResult(AParent.GUID, AParent.PropName, AParent.PhotoCount)
) +
'';
{
result := result + StringRepeat(cIndentString, ALevel - 1) +
'<a href="javascript:getHTML(''%var:PageOffset/./modules/labeltree.psc'', ''' + AParent.GUID + ''', ''GUID=' + AParent.GUID + '&showCounts=' + iif(AShowCounts, 'y', 'n') + '&expand=n&level=' + IntToStr(ALevel) + ''');">' +
' <img src="%var:PageOffset/images/collapse.gif">' +
'</a> ' +
FormatResult(AParent.GUID, AParent.PropName, AParent.PhotoCount) +
''
}
end
else
begin
if ACatParent then
ALink := 'javascript:getHTML(''%var:PageOffset/./modules/labeltree.psc'', ''' + AParent.GUID + ''', ''GUID=' + AParent.GUID + '&showCounts=' + iif(AShowCounts, 'y', 'n') + '&expand=y&level=' + IntToStr(ALevel) + ''')'
else
ALink := 'javascript:getHTML(''%var:PageOffset/./modules/labeltree.psc'', ''' + AParent.GUID + ''', ''GUID=' + AParent.GUID + '&showCounts=' + iif(AShowCounts, 'y', 'n') + '&expand=y&level=' + IntToStr(ALevel) + ''')';
result := result + StringRepeat(cIndentString, ALevel - 1) +
'<a href="' + ALink + '">' +
' <img src="%var:PageOffset/images/expand.gif">' +
'</a> ' +
iif (ACatParent,
'<a href="' + ALink + '">' + AParent.PropName + '</a>',
FormatResult(AParent.GUID, AParent.PropName, AParent.PhotoCount)
) +
'';
end;
if AExpand then
begin
AProps := TCatalogItemProps.Create (TCatalogItemProp, '');
Catalog.EnumPropsForParent (AParentGUID, AProps, False, AShowCounts);
for i := 0 to AProps.Count - 1 do
begin
AProp := AProps.Items[i];
result := result + '<div id="' + AProp.GUID + '">';
if Catalog.PropHasSubs (AProp) then
begin
result := result + StringRepeat(cIndentString, ALevel) +
'<a href="javascript:getHTML(''%var:PageOffset/./modules/labeltree.psc'', ''' + AProp.GUID + ''', ''GUID=' + AProp.GUID + '&showCounts=' + iif(AShowCounts, 'y', 'n') + '&expand=y&level=' + IntToStr(ALevel + 1) + ''');">' +
' <img src="%var:PageOffset/images/expand.gif">' +
'</a> ' +
FormatResult(AProp.GUID, AProp.PropName, AProp.PhotoCount) +
'';
end
else
result := result + StringRepeat(cIndentString, ALevel) +
'<img src="%var:PageOffset/images/noindent.gif"> ' +
FormatResult(AProp.GUID, AProp.PropName, AProp.PhotoCount) +
'<br/>';
result := result + '</div>';
end;
AProps.Free;
end;
AParent.Free;
end;
end;
%/code